//
//  TCLYEvaluationView.m
//  YuErmuYing
//
//  Created by LYang on 16/8/23.
//  Copyright © 2016年 Tiancheng. All rights reserved.
//

#import "TCLYEvaluationView.h"
#import "Masonry.h"
@implementation TCLYEvaluationView
-(instancetype) init{
    if (self = [super init]) {
        self.evaluationNum = 0;
        for (int i = 0; i<5; i++) {
            UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
            [btn setImage:[UIImage imageNamed:@"mineStar"] forState:UIControlStateNormal];
            [btn setImage:[UIImage imageNamed:@"mineStar-click"] forState:UIControlStateSelected];
            btn.tag = 100+i;
            [btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
            [self addSubview:btn];
            [btn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(self);
                make.left.mas_equalTo(self.mas_left).offset(i*20);
                make.width.mas_equalTo(15);
                make.height.mas_equalTo(15);
            }];
        }
        UIButton * btn = [self viewWithTag:100];
        btn.selected = YES;
    }
    return self;
}

-(void)btnAction:(id) sender{
    UIButton * btn1 = [self viewWithTag:100];
    UIButton * btn2 = [self viewWithTag:101];
    UIButton * btn3 = [self viewWithTag:102];
    UIButton * btn4 = [self viewWithTag:103];
    UIButton * btn5 = [self viewWithTag:104];
    switch (((UIButton *) sender).tag) {
        case 100:{
            btn1.selected = YES;
            btn2.selected = NO;
            btn3.selected = NO;
            btn4.selected = NO;
            btn5.selected = NO;
        }
            break;
        case 101:{
            btn1.selected = YES;
            btn2.selected = YES;
            btn3.selected = NO;
            btn4.selected = NO;
            btn5.selected = NO;
        }
            break;
        case 102:{
            btn1.selected = YES;
            btn2.selected = YES;
            btn3.selected = YES;
            btn4.selected = NO;
            btn5.selected = NO;
        }
            break;
        case 103:{
            btn1.selected = YES;
            btn2.selected = YES;
            btn3.selected = YES;
            btn4.selected = YES;
            btn5.selected = NO;
        }
            break;
        case 104:{
            btn1.selected = YES;
            btn2.selected = YES;
            btn3.selected = YES;
            btn4.selected = YES;
            btn5.selected = YES;
        }
            break;
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
